package com.bsoft.exchange.controller.appointmentandregistration;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.bsoft.exchange.pojo.AppointmentPayCancelPojo;
import com.bsoft.exchange.pojo.ReturnVisitPaymentCancelPojo;
import com.bsoft.exchange.response.ResponseEntity;
import com.bsoft.exchange.service.AppointmentPayCancelService;
import com.bsoft.exchange.util.BaseResponse;
import com.bsoft.exchange.util.Constant;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping(value = "appointment")
public class AppointmentPayCancelController {
	@Autowired
	private AppointmentPayCancelService appointmentPayCancelService;
	@ApiOperation(value = "预约取消")
	@RequestMapping(value = "/appointmentPayCancel",method = RequestMethod.POST,produces = "application/json")
	@ResponseBody
	public ResponseEntity<String> appointmentPayCancel(@RequestBody AppointmentPayCancelPojo appointmentPayCancelPojo)  {
		ResponseEntity<String> entity=new ResponseEntity();
		try{
		BaseResponse<String> returnMessage = appointmentPayCancelService.appointmentPayCancel(appointmentPayCancelPojo);
		
		if (returnMessage.getCode()==Constant.errorTag){
        	entity.setCode(Constant.successResponse);
        	entity.setMessage(returnMessage.getMessage());
            return entity;
        }
	
	
	 	entity.setData(returnMessage.getData());}
		catch(Exception e){
			entity.setCode(Constant.errorTag);
			entity.setMessage(e.getMessage()); 
		}


	return entity;

	}
	
	@ApiOperation(value = "复诊配药申请取消")
	@ResponseBody
	@RequestMapping(value = "/returnVisitPaymentCancel",method = RequestMethod.POST,produces = "application/json")

	public ResponseEntity<String> returnVisitPaymentCancel(@RequestBody ReturnVisitPaymentCancelPojo returnVisitPaymentCancelPojo)  {
		ResponseEntity<String> entity=new ResponseEntity();
		try{
		BaseResponse<String> returnMessage = appointmentPayCancelService.returnVisitPaymentCancel(returnVisitPaymentCancelPojo);
		
		if (returnMessage.getCode()==Constant.errorTag){
        	entity.setCode(Constant.errorTag);
        	entity.setMessage(returnMessage.getMessage());
            return entity;
        }
	
	
	 entity.setData(returnMessage.getData());}
		catch(Exception e){
			entity.setCode(Constant.errorTag);
			entity.setMessage(e.getMessage()); 
		}


	return entity;

	}

}
